package com.th.supcom.pds.impl.service.adapter;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.th.supcom.pds.domain.vo.PatientInfo;
import com.th.supcom.pds.medicare.api.AdapterMedicalCardService;
import com.th.supcom.pts.external.patient.api.query.PatientVisitMapInfoQueryService;

/**
 * 就诊卡，患者信息 调用PTS的接口
 * 
 * @author 杨冲;
 */
public class AdapterMedicalCardServiceImpl implements AdapterMedicalCardService
{

    private PatientVisitMapInfoQueryService m_patientVisitMapInfoQueryService;

    @Override
    public PatientInfo getCardInfo (String trackData, String indentityType, String prescSource)
    {
        s_logger.info ("调用PTS服务（得到患者基本信息）! call getCardInfo (String cardNo = 【{}】)", new Object[]
        { trackData });
        Map <String, Object> inmap = new HashMap <String, Object> ();
        inmap.put ("requestId", "getCardAndPatientInfo");
        inmap.put ("cardTrack", trackData);
        inmap.put ("cardTypeCode", indentityType);
        inmap.put ("visitType", prescSource);
        Map <String, Object> outmap = m_patientVisitMapInfoQueryService.getPatientVisitInfoByCard (inmap);
        @SuppressWarnings ("unchecked")
        Map <String, Object>resultMap=(Map <String, Object>) outmap.get ("result");
        PatientInfo attendanceCard = ChangeToCardNeedInfo.turnToAttendanceCard (resultMap);
        if(attendanceCard!=null){
            attendanceCard.setTrackData (trackData);
        }
        s_logger.info ("调用P服务（得到患者基本信息）结束! ");
        return attendanceCard;
    }

    public void setPatientVisitMapInfoQueryService (PatientVisitMapInfoQueryService patientVisitMapInfoQueryService)
    {

        m_patientVisitMapInfoQueryService = patientVisitMapInfoQueryService;
    }

    /** 日志记录器. */
    private static Logger s_logger = LoggerFactory.getLogger (AdapterMedicalCardServiceImpl.class);

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, TH Supcom Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

}
